<template>
    <div class="show_img">
        <el-image :src="props.element.url" />
        <div v-if="props.element.isCover" class="tip">封面</div>
        <div class="msk">
            <div class="set_cover" v-if="!props.element.isCover" @click="onSetCover">设为封面</div>
            <el-icon class="delete_icon" @click="onDelete"><Delete /></el-icon>
        </div>
    </div>
</template>

<script setup>
const props = defineProps({
    element: { type: Object }
});
const emit = defineEmits(['setCover', 'delete']);
const onSetCover = () => {
    emit('setCover', props.element);
};
const onDelete = () => {
    emit('delete', props.element);
};
</script>

<style lang="scss" scoped>
.show_img {
    width: 120px;
    height: 120px;
    box-sizing: border-box;
    background: #f8f8f8;
    border-radius: 4px;
    border: 2px solid #eaeaea;
    position: relative;
    &:hover {
        .msk {
            display: block;
        }
    }
    .el-image {
        width: 118px;
        height: 118px;
        border-radius: 4px;
        position: absolute;
        top: -1px;
        left: -1px;
    }
    .tip {
        position: absolute;
        bottom: -2px;
        left: -2px;
        width: 120px;
        height: 24px;
        border-radius: 0 0 4px 4px;
        background: rgb(51, 48, 45, 0.4);
        text-align: center;
        line-height: 24px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
    }
    .msk {
        display: none;
        position: absolute;
        top: -2px;
        left: -2px;
        width: 120px;
        height: 120px;
        background: rgba(51, 48, 45, 0.6);
        border-radius: 4px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        line-height: 17px;
        text-align: center;
        line-height: 120px;
        .set_cover {
            cursor: pointer;
        }
        .delete_icon {
            position: absolute;
            right: 8px;
            top: 8px;
            font-size: 18px;
            cursor: pointer;
            &:hover {
                color: #ff6b00;
            }
        }
    }
}
</style>
